package com.example.japinhands.data

import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.PrimaryKey
import com.example.japinhands.data.WordConstant.DEFORM_NULL
import kotlinx.parcelize.Parcelize

@Entity(
    tableName = "word",
//    foreignKeys = [
//        ForeignKey(
//            entity = DeformVerb::class,
//            parentColumns = ["id"],
//            childColumns = ["deformVerb"]
//        ),
//        ForeignKey(
//            entity = DeformAdj::class,
//            parentColumns = ["id"],
//            childColumns = ["deformAdj"]
//        )
//    ]
)
@Parcelize
data class Word(
    @PrimaryKey(autoGenerate = true)
    var id: Long = 0,
    var kanji: String = "",
    var gana: String = "",
    var meaning: String = "",
    var notice: String = "",
    var type: Int = WordConstant.NONE,
    @ColumnInfo(name = "sentence_content") var sentenceContent: String = "",
    @ColumnInfo(name = "deform_verb") var deformVerb: Long = -1L,
    @ColumnInfo(name = "deform_adj") var deformAdj: Long = -1L,
    @Deprecated("We don't need sentence table any more.")
    @Ignore var sentenceKey: Long = -1L,
) : Parcelable {
    override fun toString(): String {
        return "Word(id=$id, kanji='$kanji', gana='$gana', meaning='$meaning', notice='$notice', type=$type, deformVerb=$deformVerb, deformAdj=$deformAdj, sentenceKey=$sentenceKey)"
    }
}


@Entity("deform_verb")
data class DeformVerb(
    @PrimaryKey(autoGenerate = true)
    var id: Long = 0,
    var deform1: String = DEFORM_NULL,
    var deform2: String = DEFORM_NULL,
    var deform3: String = DEFORM_NULL,
    var deform4: String = DEFORM_NULL,
    var deform5: String = DEFORM_NULL,
    var deform6: String = DEFORM_NULL,
    var deform7: String = DEFORM_NULL,
    var deform8: String = DEFORM_NULL,
    var deform9: String = DEFORM_NULL,
    var deform10: String = DEFORM_NULL,
    var deform11: String = DEFORM_NULL,
    var deform12: String = DEFORM_NULL
) {
    override fun toString(): String {
        return "DeformVerb(id=$id, deform1='$deform1', deform2='$deform2', deform3='$deform3', deform4='$deform4', deform5='$deform5', deform6='$deform6', deform7='$deform7', deform8='$deform8', deform9='$deform9', deform10='$deform10', deform11='$deform11', deform12='$deform12')"
    }
}

@Entity("deform_adj")
data class DeformAdj(
    @PrimaryKey(autoGenerate = true)
    var id: Long = 0,
    var deform1: String = DEFORM_NULL,
    var deform2: String = DEFORM_NULL,
    var deform3: String = DEFORM_NULL,
    var deform4: String = DEFORM_NULL
) {
    override fun toString(): String {
        return "DeformAdj(id=$id, deform1='$deform1', deform2='$deform2', deform3='$deform3', deform4='$deform4')"
    }
}

@Deprecated("Only one primary key is not good to be separated.")
@Entity("sentence")
data class Sentence(
    @PrimaryKey(autoGenerate = true)
    var id: Long = 0,
    var content: String
) {
    override fun toString(): String {
        return "Sentence(id=$id, content='$content')"
    }
}